home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 106 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What's so different about 2-D arrays???
  5. Date: Mon, 01 Jan 96 21:12:27 GMT
  6. Organization: none
  7. Message-ID: <820530747snz@genesis.demon.co.uk>
  8. References: <4c799b$q9d@umbc9.umbc.edu> <4c8kdh$4qg@news1.usa.pipeline.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4c8kdh$4qg@news1.usa.pipeline.com>
  15.            grantp@usa.pipeline.com(Pete) "Pete" writes:
  16.  
  17. >>Please read the FAQ. This will show you why 'int main (void)' is the
  18. >correct 
  19. >>declaration for your particular program. 
  20. >As long as we're being so nit-picky, where in the FAQ does it say 
  21. >exactly that?  All I can find is "int main ()". 
  22.  
  23. 11.12:    Can I declare main() as void, to shut off these annoying "main
  24.     returns no value" messages?
  25.  
  26. A:    No.  main() must be declared as returning an int, and as taking
  27.     either zero or two arguments, of the appropriate types.  If
  28.     you're calling exit() but still getting warnings, you may have
  29.     to insert a redundant return statement (or use some kind of "not
  30.     reached" directive, if available).
  31.  
  32.     Declaring a function as void does not merely shut off or
  33.     rearrange warnings: it may also result in a different function
  34.     call/return sequence, incompatible with what the caller (in
  35.     main's case, the C run-time startup code) expects.
  36.  
  37. The difference between int main() and int main(void) is rather acedemic and
  38. isn't an issue here. They mean the same thing but the ANSI standard
  39. classes the former as an "obsolescent feature" which suggests that support
  40. for it may be dropped in future revisions of the language.
  41.  
  42. -- 
  43. -----------------------------------------
  44. Lawrence Kirby | fred@genesis.demon.co.uk
  45. Wilts, England | 70734.126@compuserve.com
  46. -----------------------------------------
  47.